class SessionsController < ApplicationController
  skip_before_filter :authorize
  
  def create
    if User.find_by_name_and_password(params[:user][:name], params[:user][:password])
      session[:autentikoitu] = User.find_by_name(params[:user][:name]).id
    else
      flash[:error] = "Bad username or password."
    end
    redirect_to root_url
  end
  
  def destroy
    reset_session
    redirect_to root_url
  end
end
